package eshttp

import (
	"net/http"
	"strconv"

	"github.com/zeromicro/go-zero/rest/httpx"
)

func ExportExcelFile(w http.ResponseWriter, fileName string, content []byte) error {
	w.Header().Set("Content-Disposition", "attachment; filename="+fileName)
	w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
	w.Header().Set("Content-Transfer-Encoding", "binary")
	w.Header().Set("Content-Length", strconv.Itoa(len(content)))
	w.Write(content)
	httpx.Ok(w)
	return nil
}
